package com.xie.smfs.registry;

import com.xie.smfs.Smfs;
import com.xie.smfs.block.entity.GhostCoffinBlockEntity;
import com.xie.smfs.block.entity.RedCoffinBlockEntity;
import com.xie.smfs.block.entity.GoldCoffinBlockEntity;
import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityTypeBuilder;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.util.Identifier;

public final class ModBlockEntities {
    public static BlockEntityType<GhostCoffinBlockEntity> GHOST_COFFIN_BLOCK_ENTITY;
    public static BlockEntityType<RedCoffinBlockEntity> RED_COFFIN_BLOCK_ENTITY;
    public static BlockEntityType<GoldCoffinBlockEntity> GOLD_COFFIN_BLOCK_ENTITY;

    public static void registerBlockEntities() {
        // 先创建BlockEntityType实例
        GHOST_COFFIN_BLOCK_ENTITY = FabricBlockEntityTypeBuilder.create(
                GhostCoffinBlockEntity::new,
                ModBlocks.GHOST_COFFIN
        ).build();

        // 红棺材方块实体
        RED_COFFIN_BLOCK_ENTITY = FabricBlockEntityTypeBuilder.create(
                RedCoffinBlockEntity::new,
                ModBlocks.RED_COFFIN
        ).build();

        // 黄金棺材方块实体
        GOLD_COFFIN_BLOCK_ENTITY = FabricBlockEntityTypeBuilder.create(
                GoldCoffinBlockEntity::new,
                ModBlocks.GOLD_COFFIN
        ).build();

        // 注册方块实体
        Registry.register(Registries.BLOCK_ENTITY_TYPE,
                new Identifier("smfs", "ghost_coffin_block_entity"),
                GHOST_COFFIN_BLOCK_ENTITY);
        Registry.register(Registries.BLOCK_ENTITY_TYPE,
                new Identifier("smfs", "red_coffin_block_entity"),
                RED_COFFIN_BLOCK_ENTITY);
        Registry.register(Registries.BLOCK_ENTITY_TYPE,
                new Identifier("smfs", "gold_coffin_block_entity"),
                GOLD_COFFIN_BLOCK_ENTITY);

        Smfs.LOGGER.info("Registered all coffin block entities");
    }
}